<?php
	$servername = "localhost";
	$username = "root";
	$password = "";
	$dbname = "db_books";
	try{
		
		$db = new PDO("mysql:host=$servername;dbname=$dbname;charset=UTF8", $username, $password);
    	$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    	
    	$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
		function getBook($db){
    		$query = $db->prepare("SELECT * FROM tbl_posting");
    		$query->execute();
    		$result = $query->fetchAll(PDO::FETCH_ASSOC);
    		return $result;
    	}

	}catch(PDOException $e){
		echo "Connection failed: " . $e->getMessage();
	}

	


 ?>